var name = 'window' //window.name = 'window'
var person1 = {
  name: 'person1',
  foo1: function () {
    console.log(this.name)
  },
  foo2: () => {
    console.log(this.name);
  },
  foo3: function () {
    return function () {
      console.log(this.name)
    }
  },
  foo4: function () {
    return () => {
      console.log(this.name)
    }
  }
  
}

var person2 = {
  name: 'person2'
}

person1.foo1() //隐式调用 person1
person1.foo1.call(person2) //显示绑定优先级高于隐式绑定 person2

person1.foo2() //箭头函数寻找上层作用域，不会进行隐式绑定， window
person1.foo2.call(person2) //箭头函数寻找上层作用域，不会进行隐式绑定， window

console.log(person1.foo3()) //f(){console.log(this.name)}
person1.foo3()() //window
person1.foo3.call(person2)() //window
person1.foo3().call(person2) //person2

console.log(person1.foo4());
person1.foo4()() //箭头函数this向上层作用域找 person1
person1.foo4.call(person2)() //person2
person1.foo4().call(person2) //person1
